package javase.ch01.homeWork;

import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Test01 {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new FileReader("JavaSE\\a.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("JavaSE\\a.txt"));

        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "一", "二", "三", "四", "五", "六", "七", "八", "九", "十");
        HashMap<Integer, String> map = new HashMap<>();

        String line;
        while((line = br.readLine())!=null){
            int index = list.indexOf(line.charAt(0) + "");
            map.put(index, line);
        }

        map.forEach((k,v)->{
            try {
                bw.write(v);
                bw.newLine();
                bw.flush();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        });
        br.close();
        bw.close();
        System.out.println("完成");

    }


}


